bitkeeper revision 1.1159.258.142 (428df12661vmA7WwXT170kC1Qyxpxw)
authorkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Fri, 20 May 2005 14:16:06 +0000 (14:16 +0000)
committerkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Fri, 20 May 2005 14:16:06 +0000 (14:16 +0000)
Pass CD-ROM type info through from blkback to blkfront, and interpret
correctly in blkfront. Data accesses still cause buffer underruns in
domain0 though...
Signed-off-by: Keir Fraser <keir@xensource.com>
linux-2.6.11-xen-sparse/drivers/xen/blkback/vbd.c
linux-2.6.11-xen-sparse/drivers/xen/blkfront/vbd.c

index 90d194680bbdb4590b6bee834db3bb2884f1abfa..493a2a7268aba2c80c10a377e7678a7d4808f77b 100644 (file)
@@ -65,7 +65,7 @@ void vbd_create(blkif_be_vbd_create_t *create)
 
     vbd->vdevice  = vdevice; 
     vbd->readonly = create->readonly;
-    vbd->type     = VDISK_TYPE_DISK | VDISK_FLAG_VIRT;
+    vbd->type     = VDISK_TYPE_DISK;
     vbd->extents  = NULL; 
 
     spin_lock(&blkif->vbd_lock);
@@ -163,6 +163,9 @@ void vbd_grow(blkif_be_vbd_grow_t *grow)
     else
         sz = x->bdev->bd_disk->capacity;
 
+    vbd->type = (x->bdev->bd_disk->flags & GENHD_FL_CD) ?
+        VDISK_TYPE_CDROM : VDISK_TYPE_DISK;
+
 #else
     if( !blk_size[MAJOR(x->extent.device)] )
     {
index 0110d11223421ab70a9b18ab65da5dd3a7e817e8..9a33656469541b0756ecd220ca900c76c986fadc 100644 (file)
@@ -278,15 +278,15 @@ struct gendisk *xlvbd_alloc_gendisk(
     di->mi = mi;
     di->xd_device = disk->device;
 
-    /* Full disk rather than a single partition? */
-    if ((minor & ((1 << mi->type->partn_shift) - 1)) == 0)
+    if ((VDISK_TYPE(disk->info) == VDISK_TYPE_DISK) &&
+        ((minor & ((1 << mi->type->partn_shift) - 1)) == 0))
         nr_minors = 1 << mi->type->partn_shift;
 
     gd = alloc_disk(nr_minors);
     if ( !gd )
         goto out;
 
-    if ( nr_minors > 1 ) /* full disk? */
+    if ((VDISK_TYPE(disk->info) != VDISK_TYPE_DISK) || (nr_minors > 1))
         sprintf(gd->disk_name, "%s%c", mi->type->diskname,
                 'a' + mi->index * mi->type->disks_per_major +
                     (minor >> mi->type->partn_shift));
@@ -305,6 +305,12 @@ struct gendisk *xlvbd_alloc_gendisk(
     if ((xlbd_blk_queue == NULL) && xlvbd_blk_queue_alloc(mi->type))
             goto out_gendisk;
 
+    if (VDISK_READONLY(disk->info))
+        set_disk_ro(gd, 1);
+
+    if (VDISK_TYPE(disk->info) == VDISK_TYPE_CDROM)
+        gd->flags |= GENHD_FL_REMOVABLE | GENHD_FL_CD;
+
     gd->queue = xlbd_blk_queue;
     add_disk(gd);
     return gd;
@@ -347,24 +353,6 @@ static int xlvbd_device_add(struct list_head *list, vdisk_t *disk)
     if (gd == NULL)
         goto out_bd;
 
-    if (VDISK_READONLY(disk->info))
-        set_disk_ro(gd, 1);
-
-    switch (VDISK_TYPE(disk->info)) {
-    case VDISK_TYPE_CDROM:
-        gd->flags |= GENHD_FL_REMOVABLE | GENHD_FL_CD;
-        break;
-    case VDISK_TYPE_FLOPPY: 
-    case VDISK_TYPE_TAPE:
-        gd->flags |= GENHD_FL_REMOVABLE;
-        break;
-    case VDISK_TYPE_DISK:
-        break;
-    default:
-        WPRINTK("unknown device type %d\n", VDISK_TYPE(disk->info));
-        break;
-    }    
-
     list_add(&new->list, list);
 out_bd:
     bdput(bd);